package com.itbb.config;

import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.PropertySource;

import javax.sql.DataSource;

/**
 * @Author: Insight
 * @Description: TODO
 * @Date: 2024-03-22 19:24
 * @Version: 1.0
 */
@PropertySource("clsspath:jdbc.properties")
public class JdbcConfig {
    @Value("{jdbc.driverClassName}")
    private String driver;
    @Value("{jdbc.url}")
    private String url;
    @Value("{jdbc.username}")
    private String username;
    @Value("{jdbc.password}")
    private String password;
    @Bean("dataSource")
    public DataSource getDataSource(){
        DruidDataSource ds = new DruidDataSource();
        ds.setDriverClassName(driver);
        ds.setUrl(url);
        ds.setPassword(password);
        ds.setUsername(username);
        return ds;
    }
}
